package mirfordevoservice.system.req.impl;

import mirfordevoservice.system.GameCenter.GameDataManager;
import mirfordevoservice.system.req.inter_face.ReqMessage;
import publicPackage.human.Role;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

/**
 * Created by Heart!
 *
 * @Author ZhangChaoJian
 * @Date ${Date}-19:14
 * Wants More Then Try Hard More!
 */

/**
 * 删除人物消息处理方法
 */
public class ReqDeleteHuman implements ReqMessage {
    @Override
    public void receive(ObjectInputStream in, Socket socket) {

    }

    @Override
    public void sendMsg(ObjectOutputStream out) {
    }

    @Override
    public void receiveAndSend(ObjectInputStream in, ObjectOutputStream out, Socket socket) {
        Role role = null;
        try {
            Object msg_one = in.readObject();
            Object msg_two = in.readObject();
            if ((msg_one instanceof Long) && (msg_two instanceof Integer)) {
                role = GameDataManager.getInstance().deleteHumanByRole((Long) msg_one, (Integer) msg_two);
            } else {
                System.err.println("客户端发送错误数据" + this.getClass().getName());
            }
            out.writeObject(role);
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
